Code source

Replicated code from Jenny Trickey’s repo here

Trip/drift: CalCurCEAS_2024_017

Summaries generated: 2025 Jun 10 14:30 UTC

Setup

Load needed libraries.

# load all libraries
devtools::install_github('taikisan21/PAMpal')
library(PAMpal)
# library(kableExtra) # known bug with R ver 4.3.0 so install from github
devtools::install_github('kupietz/kableExtra')
library(kableExtra)
library(ggplot2)
library(RSQLite)
library(tuneR)
# library(wesanderson)
library(here)
library(DBI)

# I don't think we need these but saving here in case
library(dplyr)
# library(tcltk)
# library(manipulate)

Set user-defined variables.

# name project
# ProjID <- 'MHI UxS Glider Project'

# combine trip, recorder, pg version (all defined in YAML) to single run string
# dbFileStr <- paste0(params$mission, '_', params$drift, '_Kogia_', params$pgver)

# define subfolder paths based on selected analysis folder and trip strings
# path_to_db <- file.path(params$path_pg, 'Database')
# path_to_binaries <- file.path(params$path_pg, 'Binaries', params$drift)
path_to_binaries <- choose.dir(default="", caption = "Select path to specific drift main binaries folder")
# assemble some file names
# pamguard database
# dbFile <- file.path(path_to_db, paste0(dbFileStr, '.sqlite3'))
dbFile <- file.choose()
# dbFile <- choose.files(default = "", caption = "Select database file", multi = FALSE)
# already processed acoustic study 'dets' file
detsFile <- file.path(params$path_dets, paste0(params$mission, '_', params$drift,'/', params$mission, '_2024_', params$drift, '_Filtered.rdata'))
detsFiltFile <- file.path(params$path_dets, 
                          paste0(params$mission, '_', params$drift,'/', params$mission, '_2024_', params$drift, '_', params$channelStr, '.rdata'))
# specify calibration file
# calFile <- params$calFile # pull from YAML

# set path to reference spectra if will be used
path_to_refSpec <- file.path(params$path_to_refSpec) # pull from YAML
# specify which reference spectra to plot
# refSpecList = c('Gm', 'Pc')
refSpecList <- params$refSpecList # pull from YAML
refSpecSp <- params$refSpecSp


# ALTERNATIVE SELECT PATHS
# path_pg <- choose.dir(default = "", caption = "Select path to pamguard folder that contains databases and binaries folders")
# # select path to database files 
# path_to_db <- choose.dir(default = "", caption = "Select path to folder with all database files") 
# # select path to specific binary drift file
# path_to_binaries <- choose.dir(default="", caption = "Select path to specific drift main folder")

# # set up datebase driver
# sqlite <- dbDriver("SQLite") # outdated/no longer supported 

# connect to SQLite database using the newer method
con <- dbConnect(RSQLite::SQLite(), dbname = dbFile)

#Set time zone to UTC
Sys.setenv(TZ = 'UTC')

# reference spectra colors - allows for up to 6 ref specs
# pastel
# rsPalette <- c('#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', 
#                '#a6d854', '#ffd92f')
# bold
rsPalette <- c('#1b9e77', '#d95f02', '#7570b3', '#e7298a', 
               '#66a61e', '#e6ab02')

Define needed functions

Source some external functions

source(here::here('_code/functions', 'loadMultiBinaries.R'))
source(here::here('_code/functions', 'plotContours.R'))
source(here::here('_code/functions', 'clickSummary.R'))
source(here::here('_code/functions', 'whistleSummary.R'))

# if not using Rproj/here package use:
# source(file.path(params$path_code, 'R', 'functions', 'loadMultiBinaries.R'))

Load and prep AcousticStudies

If already created, load an existing dets PAMpal AcousticStudy object for event processing. We need to load both the unfiltered dets and filtered detsFilt AcousticStudies.

# load existing dets AcousticStudy (created with 
# workflow_generate_acousticStudies.R)
# load(detFile)
if (file.exists(detsFile)){
  dets <- readRDS(detsFile)
  cat('Loaded', detsFile, '\n')
} else {
  cat('No AcousticStudy \'dets\' file available', '\n')
}
## Loaded F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_017/CalCurCEAS_2024_017_Filtered.rdata
if (file.exists(detsFiltFile)){
  detsFilt <- readRDS(detsFiltFile)
  cat('Loaded', detsFiltFile, '\n')
} else {
  cat('No AcousticStudy \'detsFilt\' file available', '\n')
}
## Loaded F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_017/CalCurCEAS_2024_017_ch1.rdata
# summarize how many events
nEvents <- length(names(PAMpal::events(dets)))
# number of events may change after filtering (all clicks may be filtered out)
nEventsFilt <- length(names(PAMpal::events(detsFilt)))

Loaded F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_017/CalCurCEAS_2024_017_Filtered.rdata and F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_017/CalCurCEAS_2024_017_ch1.rdata

## Updated the locations of 1 out of 1 missing database files. 
## Updated the locations of 5908 out of 5908 missing binary files. 
## Updating files in events...
##   |                                                                                          |                                                                                  |   0%  |                                                                                          |                                                                                  |   1%  |                                                                                          |=                                                                                 |   1%  |                                                                                          |=                                                                                 |   2%  |                                                                                          |==                                                                                |   2%  |                                                                                          |==                                                                                |   3%  |                                                                                          |===                                                                               |   3%  |                                                                                          |===                                                                               |   4%  |                                                                                          |====                                                                              |   4%  |                                                                                          |====                                                                              |   5%  |                                                                                          |=====                                                                             |   6%  |                                                                                          |=====                                                                             |   7%  |                                                                                          |======                                                                            |   7%  |                                                                                          |======                                                                            |   8%  |                                                                                          |=======                                                                           |   8%  |                                                                                          |=======                                                                           |   9%  |                                                                                          |========                                                                          |   9%  |                                                                                          |========                                                                          |  10%  |                                                                                          |=========                                                                         |  10%  |                                                                                          |=========                                                                         |  11%  |                                                                                          |=========                                                                         |  12%  |                                                                                          |==========                                                                        |  12%  |                                                                                          |==========                                                                        |  13%  |                                                                                          |===========                                                                       |  13%  |                                                                                          |===========                                                                       |  14%  |                                                                                          |============                                                                      |  14%  |                                                                                          |============                                                                      |  15%  |                                                                                          |=============                                                                     |  15%  |                                                                                          |=============                                                                     |  16%  |                                                                                          |==============                                                                    |  17%  |                                                                                          |==============                                                                    |  18%  |                                                                                          |===============                                                                   |  18%  |                                                                                          |===============                                                                   |  19%  |                                                                                          |================                                                                  |  19%  |                                                                                          |================                                                                  |  20%  |                                                                                          |=================                                                                 |  20%  |                                                                                          |=================                                                                 |  21%  |                                                                                          |==================                                                                |  21%  |                                                                                          |==================                                                                |  22%  |                                                                                          |==================                                                                |  23%  |                                                                                          |===================                                                               |  23%  |                                                                                          |===================                                                               |  24%  |                                                                                          |====================                                                              |  24%  |                                                                                          |====================                                                              |  25%  |                                                                                          |=====================                                                             |  25%  |                                                                                          |=====================                                                             |  26%  |                                                                                          |======================                                                            |  26%  |                                                                                          |======================                                                            |  27%  |                                                                                          |=======================                                                           |  27%  |                                                                                          |=======================                                                           |  28%  |                                                                                          |=======================                                                           |  29%  |                                                                                          |========================                                                          |  29%  |                                                                                          |========================                                                          |  30%  |                                                                                          |=========================                                                         |  30%  |                                                                                          |=========================                                                         |  31%  |                                                                                          |==========================                                                        |  31%  |                                                                                          |==========================                                                        |  32%  |                                                                                          |===========================                                                       |  32%  |                                                                                          |===========================                                                       |  33%  |                                                                                          |============================                                                      |  34%  |                                                                                          |============================                                                      |  35%  |                                                                                          |=============================                                                     |  35%  |                                                                                          |=============================                                                     |  36%  |                                                                                          |==============================                                                    |  36%  |                                                                                          |==============================                                                    |  37%  |                                                                                          |===============================                                                   |  37%  |                                                                                          |===============================                                                   |  38%  |                                                                                          |================================                                                  |  38%  |                                                                                          |================================                                                  |  39%  |                                                                                          |================================                                                  |  40%  |                                                                                          |=================================                                                 |  40%  |                                                                                          |=================================                                                 |  41%  |                                                                                          |==================================                                                |  41%  |                                                                                          |==================================                                                |  42%  |                                                                                          |===================================                                               |  42%  |                                                                                          |===================================                                               |  43%  |                                                                                          |====================================                                              |  43%  |                                                                                          |====================================                                              |  44%  |                                                                                          |=====================================                                             |  45%  |                                                                                          |=====================================                                             |  46%  |                                                                                          |======================================                                            |  46%  |                                                                                          |======================================                                            |  47%  |                                                                                          |=======================================                                           |  47%  |                                                                                          |=======================================                                           |  48%  |                                                                                          |========================================                                          |  48%  |                                                                                          |========================================                                          |  49%  |                                                                                          |=========================================                                         |  49%  |                                                                                          |=========================================                                         |  50%  |                                                                                          |=========================================                                         |  51%  |                                                                                          |==========================================                                        |  51%  |                                                                                          |==========================================                                        |  52%  |                                                                                          |===========================================                                       |  52%  |                                                                                          |===========================================                                       |  53%  |                                                                                          |============================================                                      |  53%  |                                                                                          |============================================                                      |  54%  |                                                                                          |=============================================                                     |  54%  |                                                                                          |=============================================                                     |  55%  |                                                                                          |==============================================                                    |  56%  |                                                                                          |==============================================                                    |  57%  |                                                                                          |===============================================                                   |  57%  |                                                                                          |===============================================                                   |  58%  |                                                                                          |================================================                                  |  58%  |                                                                                          |================================================                                  |  59%  |                                                                                          |=================================================                                 |  59%  |                                                                                          |=================================================                                 |  60%  |                                                                                          |==================================================                                |  60%  |                                                                                          |==================================================                                |  61%  |                                                                                          |==================================================                                |  62%  |                                                                                          |===================================================                               |  62%  |                                                                                          |===================================================                               |  63%  |                                                                                          |====================================================                              |  63%  |                                                                                          |====================================================                              |  64%  |                                                                                          |=====================================================                             |  64%  |                                                                                          |=====================================================                             |  65%  |                                                                                          |======================================================                            |  65%  |                                                                                          |======================================================                            |  66%  |                                                                                          |=======================================================                           |  67%  |                                                                                          |=======================================================                           |  68%  |                                                                                          |========================================================                          |  68%  |                                                                                          |========================================================                          |  69%  |                                                                                          |=========================================================                         |  69%  |                                                                                          |=========================================================                         |  70%  |                                                                                          |==========================================================                        |  70%  |                                                                                          |==========================================================                        |  71%  |                                                                                          |===========================================================                       |  71%  |                                                                                          |===========================================================                       |  72%  |                                                                                          |===========================================================                       |  73%  |                                                                                          |============================================================                      |  73%  |                                                                                          |============================================================                      |  74%  |                                                                                          |=============================================================                     |  74%  |                                                                                          |=============================================================                     |  75%  |                                                                                          |==============================================================                    |  75%  |                                                                                          |==============================================================                    |  76%  |                                                                                          |===============================================================                   |  76%  |                                                                                          |===============================================================                   |  77%  |                                                                                          |================================================================                  |  77%  |                                                                                          |================================================================                  |  78%  |                                                                                          |================================================================                  |  79%  |                                                                                          |=================================================================                 |  79%  |                                                                                          |=================================================================                 |  80%  |                                                                                          |==================================================================                |  80%  |                                                                                          |==================================================================                |  81%  |                                                                                          |===================================================================               |  81%  |                                                                                          |===================================================================               |  82%  |                                                                                          |====================================================================              |  82%  |                                                                                          |====================================================================              |  83%  |                                                                                          |=====================================================================             |  84%  |                                                                                          |=====================================================================             |  85%  |                                                                                          |======================================================================            |  85%  |                                                                                          |======================================================================            |  86%  |                                                                                          |=======================================================================           |  86%  |                                                                                          |=======================================================================           |  87%  |                                                                                          |========================================================================          |  87%  |                                                                                          |========================================================================          |  88%  |                                                                                          |=========================================================================         |  88%  |                                                                                          |=========================================================================         |  89%  |                                                                                          |=========================================================================         |  90%  |                                                                                          |==========================================================================        |  90%  |                                                                                          |==========================================================================        |  91%  |                                                                                          |===========================================================================       |  91%  |                                                                                          |===========================================================================       |  92%  |                                                                                          |============================================================================      |  92%  |                                                                                          |============================================================================      |  93%  |                                                                                          |=============================================================================     |  93%  |                                                                                          |=============================================================================     |  94%  |                                                                                          |==============================================================================    |  95%  |                                                                                          |==============================================================================    |  96%  |                                                                                          |===============================================================================   |  96%  |                                                                                          |===============================================================================   |  97%  |                                                                                          |================================================================================  |  97%  |                                                                                          |================================================================================  |  98%  |                                                                                          |================================================================================= |  98%  |                                                                                          |================================================================================= |  99%  |                                                                                          |==================================================================================|  99%  |                                                                                          |==================================================================================| 100%
## Updated the locations of 1 out of 1 missing database files. 
## Updated the locations of 5908 out of 5908 missing binary files. 
## Updating files in events...
##   |                                                                                          |                                                                                  |   0%  |                                                                                          |                                                                                  |   1%  |                                                                                          |=                                                                                 |   1%  |                                                                                          |=                                                                                 |   2%  |                                                                                          |==                                                                                |   2%  |                                                                                          |==                                                                                |   3%  |                                                                                          |===                                                                               |   3%  |                                                                                          |===                                                                               |   4%  |                                                                                          |====                                                                              |   4%  |                                                                                          |====                                                                              |   5%  |                                                                                          |=====                                                                             |   6%  |                                                                                          |=====                                                                             |   7%  |                                                                                          |======                                                                            |   7%  |                                                                                          |======                                                                            |   8%  |                                                                                          |=======                                                                           |   8%  |                                                                                          |=======                                                                           |   9%  |                                                                                          |========                                                                          |   9%  |                                                                                          |========                                                                          |  10%  |                                                                                          |=========                                                                         |  10%  |                                                                                          |=========                                                                         |  11%  |                                                                                          |=========                                                                         |  12%  |                                                                                          |==========                                                                        |  12%  |                                                                                          |==========                                                                        |  13%  |                                                                                          |===========                                                                       |  13%  |                                                                                          |===========                                                                       |  14%  |                                                                                          |============                                                                      |  14%  |                                                                                          |============                                                                      |  15%  |                                                                                          |=============                                                                     |  15%  |                                                                                          |=============                                                                     |  16%  |                                                                                          |==============                                                                    |  17%  |                                                                                          |==============                                                                    |  18%  |                                                                                          |===============                                                                   |  18%  |                                                                                          |===============                                                                   |  19%  |                                                                                          |================                                                                  |  19%  |                                                                                          |================                                                                  |  20%  |                                                                                          |=================                                                                 |  20%  |                                                                                          |=================                                                                 |  21%  |                                                                                          |==================                                                                |  21%  |                                                                                          |==================                                                                |  22%  |                                                                                          |==================                                                                |  23%  |                                                                                          |===================                                                               |  23%  |                                                                                          |===================                                                               |  24%  |                                                                                          |====================                                                              |  24%  |                                                                                          |====================                                                              |  25%  |                                                                                          |=====================                                                             |  25%  |                                                                                          |=====================                                                             |  26%  |                                                                                          |======================                                                            |  26%  |                                                                                          |======================                                                            |  27%  |                                                                                          |=======================                                                           |  27%  |                                                                                          |=======================                                                           |  28%  |                                                                                          |=======================                                                           |  29%  |                                                                                          |========================                                                          |  29%  |                                                                                          |========================                                                          |  30%  |                                                                                          |=========================                                                         |  30%  |                                                                                          |=========================                                                         |  31%  |                                                                                          |==========================                                                        |  31%  |                                                                                          |==========================                                                        |  32%  |                                                                                          |===========================                                                       |  32%  |                                                                                          |===========================                                                       |  33%  |                                                                                          |============================                                                      |  34%  |                                                                                          |============================                                                      |  35%  |                                                                                          |=============================                                                     |  35%  |                                                                                          |=============================                                                     |  36%  |                                                                                          |==============================                                                    |  36%  |                                                                                          |==============================                                                    |  37%  |                                                                                          |===============================                                                   |  37%  |                                                                                          |===============================                                                   |  38%  |                                                                                          |================================                                                  |  38%  |                                                                                          |================================                                                  |  39%  |                                                                                          |================================                                                  |  40%  |                                                                                          |=================================                                                 |  40%  |                                                                                          |=================================                                                 |  41%  |                                                                                          |==================================                                                |  41%  |                                                                                          |==================================                                                |  42%  |                                                                                          |===================================                                               |  42%  |                                                                                          |===================================                                               |  43%  |                                                                                          |====================================                                              |  43%  |                                                                                          |====================================                                              |  44%  |                                                                                          |=====================================                                             |  45%  |                                                                                          |=====================================                                             |  46%  |                                                                                          |======================================                                            |  46%  |                                                                                          |======================================                                            |  47%  |                                                                                          |=======================================                                           |  47%  |                                                                                          |=======================================                                           |  48%  |                                                                                          |========================================                                          |  48%  |                                                                                          |========================================                                          |  49%  |                                                                                          |=========================================                                         |  49%  |                                                                                          |=========================================                                         |  50%  |                                                                                          |=========================================                                         |  51%  |                                                                                          |==========================================                                        |  51%  |                                                                                          |==========================================                                        |  52%  |                                                                                          |===========================================                                       |  52%  |                                                                                          |===========================================                                       |  53%  |                                                                                          |============================================                                      |  53%  |                                                                                          |============================================                                      |  54%  |                                                                                          |=============================================                                     |  54%  |                                                                                          |=============================================                                     |  55%  |                                                                                          |==============================================                                    |  56%  |                                                                                          |==============================================                                    |  57%  |                                                                                          |===============================================                                   |  57%  |                                                                                          |===============================================                                   |  58%  |                                                                                          |================================================                                  |  58%  |                                                                                          |================================================                                  |  59%  |                                                                                          |=================================================                                 |  59%  |                                                                                          |=================================================                                 |  60%  |                                                                                          |==================================================                                |  60%  |                                                                                          |==================================================                                |  61%  |                                                                                          |==================================================                                |  62%  |                                                                                          |===================================================                               |  62%  |                                                                                          |===================================================                               |  63%  |                                                                                          |====================================================                              |  63%  |                                                                                          |====================================================                              |  64%  |                                                                                          |=====================================================                             |  64%  |                                                                                          |=====================================================                             |  65%  |                                                                                          |======================================================                            |  65%  |                                                                                          |======================================================                            |  66%  |                                                                                          |=======================================================                           |  67%  |                                                                                          |=======================================================                           |  68%  |                                                                                          |========================================================                          |  68%  |                                                                                          |========================================================                          |  69%  |                                                                                          |=========================================================                         |  69%  |                                                                                          |=========================================================                         |  70%  |                                                                                          |==========================================================                        |  70%  |                                                                                          |==========================================================                        |  71%  |                                                                                          |===========================================================                       |  71%  |                                                                                          |===========================================================                       |  72%  |                                                                                          |===========================================================                       |  73%  |                                                                                          |============================================================                      |  73%  |                                                                                          |============================================================                      |  74%  |                                                                                          |=============================================================                     |  74%  |                                                                                          |=============================================================                     |  75%  |                                                                                          |==============================================================                    |  75%  |                                                                                          |==============================================================                    |  76%  |                                                                                          |===============================================================                   |  76%  |                                                                                          |===============================================================                   |  77%  |                                                                                          |================================================================                  |  77%  |                                                                                          |================================================================                  |  78%  |                                                                                          |================================================================                  |  79%  |                                                                                          |=================================================================                 |  79%  |                                                                                          |=================================================================                 |  80%  |                                                                                          |==================================================================                |  80%  |                                                                                          |==================================================================                |  81%  |                                                                                          |===================================================================               |  81%  |                                                                                          |===================================================================               |  82%  |                                                                                          |====================================================================              |  82%  |                                                                                          |====================================================================              |  83%  |                                                                                          |=====================================================================             |  84%  |                                                                                          |=====================================================================             |  85%  |                                                                                          |======================================================================            |  85%  |                                                                                          |======================================================================            |  86%  |                                                                                          |=======================================================================           |  86%  |                                                                                          |=======================================================================           |  87%  |                                                                                          |========================================================================          |  87%  |                                                                                          |========================================================================          |  88%  |                                                                                          |=========================================================================         |  88%  |                                                                                          |=========================================================================         |  89%  |                                                                                          |=========================================================================         |  90%  |                                                                                          |==========================================================================        |  90%  |                                                                                          |==========================================================================        |  91%  |                                                                                          |===========================================================================       |  91%  |                                                                                          |===========================================================================       |  92%  |                                                                                          |============================================================================      |  92%  |                                                                                          |============================================================================      |  93%  |                                                                                          |=============================================================================     |  93%  |                                                                                          |=============================================================================     |  94%  |                                                                                          |==============================================================================    |  95%  |                                                                                          |==============================================================================    |  96%  |                                                                                          |===============================================================================   |  96%  |                                                                                          |===============================================================================   |  97%  |                                                                                          |================================================================================  |  97%  |                                                                                          |================================================================================  |  98%  |                                                                                          |================================================================================= |  98%  |                                                                                          |================================================================================= |  99%  |                                                                                          |==================================================================================|  99%  |                                                                                          |==================================================================================| 100%

Updated file paths to binaries in databases for F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_017/CalCurCEAS_2024_017_Filtered.rdata and F:/gcp_upload/2_Acoustic-Studies/CalCurCEAS_017/CalCurCEAS_2024_017_ch1.rdata

Create initial output Event Table CSV

To be used for manual scoring based on report figures.

# set up output data frame
evTable <- data.frame(drift = character(nEvents), id = character(nEvents), 
                      species = character(nEvents), numClicks = numeric(nEvents))
# populate with drift string and event names
evTable$drift <- paste0(params$mission, '_', params$drift)
evTable$id <- names(PAMpal::events(detsFilt))

# get all click data
allClks <- PAMpal::getClickData(detsFilt)
# get the number of clicks for each event
for (iEvent in c(1:nEventsFilt)){
  evTable$numClicks[iEvent] <- length(which(allClks$eventId == evTable$id[iEvent]))
}

# keep only rows/events with at least 200 clicks
evTable <- evTable[which(evTable$numClicks >199),]

# add column for keeping/removing based on median peak frequency
evTable$keep <- FALSE # set all to false, will mark keepers as TRUE in loop

# save event table as CSV
write.csv(evTable, file = file.path(params$path_dets,
                                    paste0('eventTable_', params$mission, '_',
                                           params$drift, '_', Sys.Date(),'.csv')))

1406 events (files) in drift. 73 events have at least 200 clicks. Additional events may be removed if the median peak frequency of all high SNR clicks is less than 6 kHz. The final number of events can be found at the very end of the report.

Load reference spectra, if specified

Load the reference spectra for plotting, if set with refSpecList.

# refSpecList is specified in YAML params. Can be one or multiple species
# for single species specify as char string without quotations e.g., refSpecPc
# for multiple species, specify with call to R and c()
#     e.g., !r c('meanSpecGm', 'refSpecPc_LLHARP')

refSpecs <- NULL
if (!is.null(refSpecList)){
  refSpecs = list()
  for (rs in refSpecList){
    refSpecs[[rs]] = read.csv(file.path(path_to_refSpec, paste0(rs, '.csv')))
  }
}

Event summaries

Loop through each detection event (n = 73) create plots and a table of summary statistics for click and whistle detections. This process uses AcousticStudy objects that have detection data for each event, and also pulls information from the Pamguard binaries associated with each AcousticStudy.

Click plots (other than the SNR plot) only show clicks with SNRs >= 15 dB.

for (iEvent in c(1:nEventsFilt)){
  # iEvent = 6 # for testing
  # ("pagebreak \n")
  
  # extract this event UID string
  eventList <- PAMpal::events(detsFilt)
  eventUID <- names(eventList)[iEvent]
  
  ###### summarize clicks ######
  cl <- clickSummary(detsFilt, eventUID) 
  
  if ((cl$nClicks > 199) && median(cl$goodClicks$peak, na.rm = TRUE) >= 6){
    # keep this in evTable
    evTable$keep[evTable$id == eventUID] <- TRUE
    evTable$medPeakFrq[evTable$id == eventUID] <- median(cl$goodClicks$peak, 
                                                         na.rm = TRUE)
    
    # set header for this event and print time
    cat('\n\n#### Event ID:   ', names(eventList)[iEvent], '\n')
    cat('Time:   ', format(eventList[[eventUID]]@ancillary$grouping$start, 
                           '%Y-%m-%d %H:%M%Z'), ' to ', 
        format(eventList[[eventUID]]@ancillary$grouping$end, '%Y-%m-%d %H:%M%Z'), 
        '\n')
    
    cat('\nEvent contains', nrow(PAMpal::getClickData(dets[[eventUID]])), 
        'original clicks,', paste0('**', cl$nClicks), 'valid clicks** after',
        'filtering.\n')
    cat('\n')
    
    ###### summarize whistles ######
    # wl <- whistleSummary(detsFilt, eventUID)
    # 
    # cat('\nEvent contains', paste0('**', wl$nWhistles), 'whistles**.\n')
    # cat('\n')
    
    ###### click plots and table ######
    
    cat('\n##### Click plots and table\n')
    cat('\n SNR histogram includes all filtered clicks. Other plots contain only', 
        'clicks with SNR >= 15 dB', paste0('(**n = ', cl$nGoodClicks, ' clicks**)'),
        '.\n')
    cat('\n')
    
    
    # if any clicks...
    if (cl$nClicks > 0){
      # histogram of all clicks and SNR >= 15 dB cut off
      xMax <- max(c(15, ceiling(max(cl$snr)) + 2)) # whichever is bigger
      if (any(!is.na(cl$snr))){
        hist(cl$snr, breaks = seq(from = floor(min(cl$snr)), 
                                  to = xMax, by = 2), 
             main = 'Click SNR', sub = '(all filtered clicks)', xlab = 'SNR')
        abline(v = 15, lty = 2, lwd = 2, col = 'red4')
      }
      
    }
    
    # if sufficient good clicks...
    if (cl$nGoodClicks > 0) {
      # histogram of click durations - good clicks only
      subStr <- paste0('(high SNR clicks, n=', cl$nGoodClicks, ')')
      hist(cl$goodClicks$duration, 
           breaks = seq(from = 0, to = max(cl$goodClicks$duration) + 100, 
                        by = 100), main = 'Click duration', sub = subStr,
           xlab = expression(paste('duration [', mu, 's]')))
      abline(v = median(cl$goodClicks$duration), lty = 2, lwd = 2, col = 'black')
      legend('topright', legend = 'median', lty = 2, lwd = 2, col = 'black')
      
      
      cat('\n')
      cat('\n')
      
      
      # Calculate and plot Concatenated and Mean Spectrum for clicks w/ max SNR > 15dB
      # NB: JLKM uses more exaggerated SNR (>40 dB) for BWs bc actual spectra may
      # be noisy for single clicks
      # reducing wl can give more accurate noise floor but 'smoother' spectrum
      # increasing wl will give more exact spectrum but may exclude too many 
      # clicks based on SNR (noise measure will overlap with click output; noise
      # is just measured as same wl from start of binary snippet and binaries 
      # binary snippets are v short)
      # Trial and error - 256 works ok for LLHARP data = 1.28 ms
      # NB: JLKM uses 500 for beaked whales with samp rate 288k
      avgSpec <- PAMpal::calculateAverageSpectra(detsFilt, evNum = eventUID, wl = 256, 
                                         channel = params$channelNum, norm = TRUE,
                                         noise = TRUE, sort = TRUE, snr = 15, 
                                         plot = c(TRUE, FALSE))
      # concatenated spectrogram will get plotted within calculation
      
      # avg spectrum plots separately (bc adding stuff)
      if (!is.null(avgSpec)) {
        # Peak freq as calculated by calculateAvgerageSpectra -for subtitle
        peakFreq <- round(avgSpec$freq[which.max(avgSpec$avgSpec)]/1000, 2)
        
        plot(1, type = 'n', xlim = c(0, 100), ylim = c(min(avgSpec$avgSpec), 0), 
             xlab = 'Frequency (kHz)', ylab = 'Normalized Magnitude (dB)', 
             main = 'Average Spectrum', sub = paste0('Peak: ', peakFreq, 'kHz'))
        # add grid lines for frequency at 10 kHz intervals
        for (iline in ((0:20)*10)) {lines(c(iline,iline), c(-100,10), col="gray")}
        # add template spectra
        if (length(refSpecs) > 0){
          rsCols <- rsPalette[1:length(refSpecs)]
          for (rs in 1:length(refSpecs)){
            rsTmp <- refSpecList[rs]
            rsNorm <- refSpecs[[rsTmp]]
            rsMax <- max(rsNorm$dB)
            rsNorm$dBNorm <- rsNorm$dB - rsMax
            lines(rsNorm$frq, rsNorm$dBNorm, col = rsCols[rs], lwd = 2)
          }
        }
        
        # plot noise
        lines(avgSpec$freq/1000, avgSpec$avgNoise, lty = 3, lwd = 2)
        # plot avg spectrum
        lines(avgSpec$freq/1000, avgSpec$avgSpec, lty = 2, lwd = 3)
        # also plot median spectrum
        medSpec <- 20*log10(apply(avgSpec$allSpec, 1, function(y) {
          median(10^(y/20), na.rm = TRUE)}))
        medSpecNorm <- medSpec - max(medSpec, na.rm = TRUE)
        lines(avgSpec$freq/1000, medSpecNorm, lty = 1, lwd = 3)
        
        # add legend
        if (length(refSpecs) > 0){
          legend(x = 'topright', c(refSpecSp, 'Avg.', 'Med.', 'Noise'),
                 lty = c(rep(1, length(refSpecs)), 2, 1, 3),
                 lwd = c(rep(1, length(refSpecs)), 2, 3, 2),
                 col = c(rsCols, 'black', 'black', 'black'), cex = 0.8)
        } else if (length(refSpecs) == 0){
          legend(x = 'topright', c('Avg.', 'Med.', 'Noise'),
                 lty = c(2, 1, 3), lwd = c(2, 3, 2),
                 col = c('black', 'black', 'black'), cex = 0.8)
        }
      }
      
      
      # NB: JLKM BW approach has additional plots here:
      # IPI
      # Waveform of strongest click
      # Wigner plot
      # We are not including those here because not really useful for FKW, but if
      # interested in adding back in, see:
      #       https://github.com/jlkeating/PAMGuard_Event_Code
      
      
      cat('\n')
      cat('\n')
      
      
      # create median stats table for clicks with -15 dB TK noise cut off
      cat('\n\n Median statistics for', cl$nGoodClicks, 'high SNR clicks with', 
          'SNR >= 15 dB.')
      cat('\n')
      
      cat(knitr::kable(cl$mt, format = 'html', caption = '', align = 'l', 
                       row.names = FALSE) %>%
            kableExtra::kable_styling(bootstrap_options = c('basic', 'condensed'),
                          full_width = F))
      
    }  else { # no good clicks so no summary plots/table
      cat('\nNo clicks of sufficient SNR to plot or summarize.\n')
    }
    
    
    ###### whistle plots and table ######
    # 
    # cat('\n##### Whistle plots and table\n')
    # 
    # # if whistles present ...
    # if (wl$nWhistles > 0) {
    #   # create median stats table for all whistles
    #   # cat('\n\n Median statistics for', wl$nWhistles, 'whistles.')
    #   # cat('\n')
    #   
    #   # plot whistle contours
    #   # map the needed binary files
    #   binFiles <- dets@events[[eventUID]]@files$binaries
    #   wmFileIdx <- grep(pattern = '^.*WhistlesMoans_Whistle_and_Moan.*\\.pgdf$',
    #                     binFiles)
    #   wmFiles <- dets@events[[eventUID]]@files$binaries[wmFileIdx]
    #   
    #   # load them
    #   whBin <- loadMultiBinaries(wmFiles)
    #   # trim to just the event time
    #   whBinEv <- whBin[names(whBin) %in%
    #                      detsFilt[[eventUID]]$Whistle_and_Moan_Detector$UID]
    #   
    #   # #plot - ggplot version/functionized
    #   # pc <- plotContours(whBinEv)
    #   # # print(pc)
    #   # pc + ggtitle(eventUID)
    #   # 
    #   
    #   # get plot limits
    #   # xMax <- 0
    #   # yMax <- 0
    #   # for (wc in 1:length(names(whBinEv))){
    #   #   df <- data.frame(time = whBinEv[[wc]]$time - whBinEv[[wc]]$time[1],
    #   #                    freq = whBinEv[[wc]]$freq/1000)
    #   #   xMaxTmp <- max(df$time)
    #   #   yMaxTmp <- max(df$freq)
    #   #   if (xMaxTmp > xMax){xMax <- xMaxTmp}
    #   #   if (yMaxTmp > yMax){yMax <- yMaxTmp}
    #   # }
    #   # or use standard max lims
    #   xMax <- 1.5
    #   yMax <- 20
    #   
    #   # plot each line
    #   plot(1, type = 'n', xlim = c(0, round(xMax,2)), ylim = c(0, round(yMax,-1)), 
    #        xlab = 'Time (s)', ylab = 'Frequency (kHz)', 
    #        main = 'Whistle Contours')
    #   # add grid lines for frequency at 0.125 s and 5 kHz intervals
    #   for (iline in (seq(0,2,0.125))) {lines(c(iline,iline), c(-10,60),
    #                                          col="lightgray")}
    #   for (iline in (seq(0,50,5))) {lines(c(-0.5,2.5), c(iline,iline),
    #                                       col="lightgray")}
    #   # loop through each contour
    #   for (wc in 1:length(names(whBinEv))){
    #     df <- data.frame(time = whBinEv[[wc]]$time - whBinEv[[wc]]$time[1],
    #                      freq = whBinEv[[wc]]$freq/1000)
    #     lines(df$time, df$freq, col = rgb(0,0,0,0.4))
    #   }
    #   
    #   # plot histogram of median frequency
    #   hist(wl$wh$freqMedian/1000, 
    #        breaks = seq(0, ceiling(max(wl$wh$freqMedian/1000)) + 1, 1),
    #        main = 'Histogram of whistle median frequency', 
    #        xlab = 'Median frequency (kHz)')
    #   
    #   cat('\n')
    #   cat('\n')
    #   
    #   cat('Median statistics for n = ', wl$nWhistles, 'whistles.\n')
    #   # create median stats table for all whistles
    #   cat(knitr::kable(wl$mt, format = 'html', caption = '', align = 'l', 
    #                    row.names = FALSE) %>%
    #         kable_styling(bootstrap_options = c('basic', 'condensed'),
    #                       full_width = F))
    #   
    # } else {
    #   cat('\nNo whistles present.\n')
    # }
    
    cat('\n')
    cat('\n\n --- \n\n')
    cat('\n')
  }# num clicks/peak freq check 
} # loop

Event ID: 7518.241007055400.wav

Time: 2024-10-07 05:54UTC to 2024-10-07 06:00UTC

Event contains 586 original clicks, 293 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 252 clicks) .

Median statistics for 252 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 11.2
Median 3dB Center Frequency [kHz] 11.1
Median 10dB Center Frequency [kHz] 12.4
Median 3dB Bandwidth [kHz] (lower-upper) 1.99 ( 9.5 - 12.6)
Median 10dB Bandwidth [kHz] (lower-upper) 9.05 (6.67 - 17.6)
Median duration [μs] (25-75 percentile) 263 (115 - 1000)

Event ID: 7518.241007073000.wav

Time: 2024-10-07 07:30UTC to 2024-10-07 07:36UTC

Event contains 714 original clicks, 357 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 287 clicks) .

Median statistics for 287 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.05
Median 10dB Center Frequency [kHz] 5.86
Median 3dB Bandwidth [kHz] (lower-upper) 1.08 ( 5.4 - 6.64)
Median 10dB Bandwidth [kHz] (lower-upper) 2.6 (4.57 - 7.19)
Median duration [μs] (25-75 percentile) 532 (186 - 1000)

Event ID: 7518.241007073600.wav

Time: 2024-10-07 07:36UTC to 2024-10-07 07:42UTC

Event contains 728 original clicks, 364 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 262 clicks) .

Median statistics for 262 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.07
Median 10dB Center Frequency [kHz] 5.95
Median 3dB Bandwidth [kHz] (lower-upper) 1.01 (5.57 - 6.6)
Median 10dB Bandwidth [kHz] (lower-upper) 2.42 (4.74 - 7.15)
Median duration [μs] (25-75 percentile) 370 (100 - 1000)

Event ID: 7518.241008042400.wav

Time: 2024-10-08 04:24UTC to 2024-10-08 04:29UTC

Event contains 622 original clicks, 311 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 150 clicks) .

Median statistics for 150 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 9.6
Median 3dB Center Frequency [kHz] 9.27
Median 10dB Center Frequency [kHz] 9.86
Median 3dB Bandwidth [kHz] (lower-upper) 1.1 (8.42 - 9.99)
Median 10dB Bandwidth [kHz] (lower-upper) 3.43 (7.13 - 11.4)
Median duration [μs] (25-75 percentile) 70 (5 - 1000)

Event ID: 7518.241008073600.wav

Time: 2024-10-08 07:36UTC to 2024-10-08 07:42UTC

Event contains 3608 original clicks, 1804 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 1399 clicks) .

Median statistics for 1399 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.97
Median 10dB Center Frequency [kHz] 5.91
Median 3dB Bandwidth [kHz] (lower-upper) 1.03 (5.42 - 6.51)
Median 10dB Bandwidth [kHz] (lower-upper) 2.39 (4.62 - 7.11)
Median duration [μs] (25-75 percentile) 873 (413 - 1354)

Event ID: 7518.241008074200.wav

Time: 2024-10-08 07:42UTC to 2024-10-08 07:48UTC

Event contains 712 original clicks, 356 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 263 clicks) .

Median statistics for 263 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6.4
Median 3dB Center Frequency [kHz] 6.63
Median 10dB Center Frequency [kHz] 6.49
Median 3dB Bandwidth [kHz] (lower-upper) 1.05 (6.12 - 7.2)
Median 10dB Bandwidth [kHz] (lower-upper) 2.85 (5.07 - 7.78)
Median duration [μs] (25-75 percentile) 633 (100 - 1129)

Event ID: 7518.241008074800.wav

Time: 2024-10-08 07:48UTC to 2024-10-08 07:53UTC

Event contains 484 original clicks, 242 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 194 clicks) .

Median statistics for 194 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.26
Median 10dB Center Frequency [kHz] 6.16
Median 3dB Bandwidth [kHz] (lower-upper) 1.09 (5.77 - 6.79)
Median 10dB Bandwidth [kHz] (lower-upper) 2.57 (4.95 - 7.35)
Median duration [μs] (25-75 percentile) 345 (100 - 1082)

Event ID: 7518.241008075400.wav

Time: 2024-10-08 07:54UTC to 2024-10-08 08:00UTC

Event contains 1312 original clicks, 656 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 505 clicks) .

Median statistics for 505 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.13
Median 10dB Center Frequency [kHz] 6.03
Median 3dB Bandwidth [kHz] (lower-upper) 0.958 (5.64 - 6.65)
Median 10dB Bandwidth [kHz] (lower-upper) 2.32 (4.62 - 7.2)
Median duration [μs] (25-75 percentile) 983 (428 - 1694)

Event ID: 7518.241008080600.wav

Time: 2024-10-08 08:06UTC to 2024-10-08 08:11UTC

Event contains 1210 original clicks, 605 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 485 clicks) .

Median statistics for 485 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.2
Median 10dB Center Frequency [kHz] 6.11
Median 3dB Bandwidth [kHz] (lower-upper) 0.922 (5.71 - 6.71)
Median 10dB Bandwidth [kHz] (lower-upper) 2.15 (4.97 - 7.28)
Median duration [μs] (25-75 percentile) 1150 (1000 - 1799)

Event ID: 7518.241008082400.wav

Time: 2024-10-08 08:24UTC to 2024-10-08 08:30UTC

Event contains 1654 original clicks, 827 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 583 clicks) .

Median statistics for 583 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.16
Median 10dB Center Frequency [kHz] 6.02
Median 3dB Bandwidth [kHz] (lower-upper) 1.02 (5.57 - 6.78)
Median 10dB Bandwidth [kHz] (lower-upper) 2.5 (4.68 - 7.32)
Median duration [μs] (25-75 percentile) 970 (314 - 1676)

Event ID: 7518.241008083000.wav

Time: 2024-10-08 08:30UTC to 2024-10-08 08:35UTC

Event contains 860 original clicks, 430 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 312 clicks) .

Median statistics for 312 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.06
Median 10dB Center Frequency [kHz] 6
Median 3dB Bandwidth [kHz] (lower-upper) 1.08 (5.49 - 6.68)
Median 10dB Bandwidth [kHz] (lower-upper) 2.57 (4.65 - 7.25)
Median duration [μs] (25-75 percentile) 903 (251 - 1326)

Event ID: 7518.241008092400.wav

Time: 2024-10-08 09:24UTC to 2024-10-08 09:30UTC

Event contains 584 original clicks, 292 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 213 clicks) .

Median statistics for 213 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.98
Median 10dB Center Frequency [kHz] 5.85
Median 3dB Bandwidth [kHz] (lower-upper) 1.01 (5.45 - 6.51)
Median 10dB Bandwidth [kHz] (lower-upper) 2.38 (4.54 - 7.06)
Median duration [μs] (25-75 percentile) 641 (128 - 1348)

Event ID: 7518.241008093600.wav

Time: 2024-10-08 09:36UTC to 2024-10-08 09:41UTC

Event contains 1746 original clicks, 873 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 539 clicks) .

Median statistics for 539 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.06
Median 10dB Center Frequency [kHz] 5.94
Median 3dB Bandwidth [kHz] (lower-upper) 0.886 (5.56 - 6.53)
Median 10dB Bandwidth [kHz] (lower-upper) 2.31 (4.68 - 7.1)
Median duration [μs] (25-75 percentile) 1212 (1000 - 2135)

Event ID: 7518.241008094200.wav

Time: 2024-10-08 09:42UTC to 2024-10-08 09:48UTC

Event contains 1262 original clicks, 631 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 378 clicks) .

Median statistics for 378 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.95
Median 10dB Center Frequency [kHz] 5.88
Median 3dB Bandwidth [kHz] (lower-upper) 0.943 (5.44 - 6.49)
Median 10dB Bandwidth [kHz] (lower-upper) 2.31 (4.71 - 7.08)
Median duration [μs] (25-75 percentile) 1176 (1000 - 1945)

Event ID: 7518.241008111800.wav

Time: 2024-10-08 11:18UTC to 2024-10-08 11:24UTC

Event contains 526 original clicks, 263 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 201 clicks) .

Median statistics for 201 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6.4
Median 3dB Center Frequency [kHz] 6.45
Median 10dB Center Frequency [kHz] 6.35
Median 3dB Bandwidth [kHz] (lower-upper) 0.998 (5.91 - 7.03)
Median 10dB Bandwidth [kHz] (lower-upper) 2.55 (5.07 - 7.75)
Median duration [μs] (25-75 percentile) 605 (175 - 1257)

Event ID: 7518.241008114200.wav

Time: 2024-10-08 11:42UTC to 2024-10-08 11:48UTC

Event contains 472 original clicks, 236 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 184 clicks) .

Median statistics for 184 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 10.4
Median 3dB Center Frequency [kHz] 9.92
Median 10dB Center Frequency [kHz] 11.8
Median 3dB Bandwidth [kHz] (lower-upper) 1.56 (8.68 - 11.3)
Median 10dB Bandwidth [kHz] (lower-upper) 6.58 (5.79 - 17.9)
Median duration [μs] (25-75 percentile) 241 (111 - 1000)

Event ID: 7518.241008123000.wav

Time: 2024-10-08 12:30UTC to 2024-10-08 12:36UTC

Event contains 2058 original clicks, 1029 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 579 clicks) .

Median statistics for 579 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.04
Median 10dB Center Frequency [kHz] 5.98
Median 3dB Bandwidth [kHz] (lower-upper) 0.966 (5.53 - 6.58)
Median 10dB Bandwidth [kHz] (lower-upper) 2.36 (4.74 - 7.18)
Median duration [μs] (25-75 percentile) 1137 (1000 - 1706)

Event ID: 7518.241008123600.wav

Time: 2024-10-08 12:36UTC to 2024-10-08 12:42UTC

Event contains 3906 original clicks, 1953 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 1245 clicks) .

Median statistics for 1245 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.92
Median 10dB Center Frequency [kHz] 5.87
Median 3dB Bandwidth [kHz] (lower-upper) 0.991 (5.36 - 6.5)
Median 10dB Bandwidth [kHz] (lower-upper) 2.4 ( 4.6 - 7.15)
Median duration [μs] (25-75 percentile) 1314 (1000 - 2054)

Event ID: 7518.241008130000.wav

Time: 2024-10-08 13:00UTC to 2024-10-08 13:06UTC

Event contains 560 original clicks, 280 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 171 clicks) .

Median statistics for 171 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.29
Median 10dB Center Frequency [kHz] 6.1
Median 3dB Bandwidth [kHz] (lower-upper) 1.05 (5.63 - 6.86)
Median 10dB Bandwidth [kHz] (lower-upper) 2.65 (4.62 - 7.51)
Median duration [μs] (25-75 percentile) 1092 (360 - 1710)

Event ID: 7518.241008133600.wav

Time: 2024-10-08 13:36UTC to 2024-10-08 13:42UTC

Event contains 470 original clicks, 235 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 154 clicks) .

Median statistics for 154 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6.4
Median 3dB Center Frequency [kHz] 6.31
Median 10dB Center Frequency [kHz] 6.14
Median 3dB Bandwidth [kHz] (lower-upper) 1.04 (5.73 - 6.82)
Median 10dB Bandwidth [kHz] (lower-upper) 2.68 (4.71 - 7.41)
Median duration [μs] (25-75 percentile) 199 (0 - 1000)

Event ID: 7518.241008134200.wav

Time: 2024-10-08 13:42UTC to 2024-10-08 13:48UTC

Event contains 1918 original clicks, 959 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 631 clicks) .

Median statistics for 631 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6.4
Median 3dB Center Frequency [kHz] 6.36
Median 10dB Center Frequency [kHz] 6.24
Median 3dB Bandwidth [kHz] (lower-upper) 0.991 (5.84 - 6.92)
Median 10dB Bandwidth [kHz] (lower-upper) 2.4 (4.93 - 7.55)
Median duration [μs] (25-75 percentile) 962 (424 - 1563)

Event ID: 7518.241008134800.wav

Time: 2024-10-08 13:48UTC to 2024-10-08 13:53UTC

Event contains 2134 original clicks, 1067 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 713 clicks) .

Median statistics for 713 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.91
Median 10dB Center Frequency [kHz] 5.83
Median 3dB Bandwidth [kHz] (lower-upper) 0.962 (5.39 - 6.48)
Median 10dB Bandwidth [kHz] (lower-upper) 2.25 (4.68 - 7.05)
Median duration [μs] (25-75 percentile) 1184 (1000 - 1754)

Event ID: 7518.241008135400.wav

Time: 2024-10-08 13:54UTC to 2024-10-08 13:59UTC

Event contains 1292 original clicks, 646 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 393 clicks) .

Median statistics for 393 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6
Median 10dB Center Frequency [kHz] 5.9
Median 3dB Bandwidth [kHz] (lower-upper) 0.962 (5.48 - 6.55)
Median 10dB Bandwidth [kHz] (lower-upper) 2.34 (4.68 - 7.12)
Median duration [μs] (25-75 percentile) 1254 (1000 - 1861)

Event ID: 7518.241008140000.wav

Time: 2024-10-08 14:00UTC to 2024-10-08 14:06UTC

Event contains 1420 original clicks, 710 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 412 clicks) .

Median statistics for 412 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.94
Median 10dB Center Frequency [kHz] 5.83
Median 3dB Bandwidth [kHz] (lower-upper) 0.961 (5.43 - 6.5)
Median 10dB Bandwidth [kHz] (lower-upper) 2.42 (4.59 - 7.06)
Median duration [μs] (25-75 percentile) 1404 (1000 - 2069)

Event ID: 7518.241008140600.wav

Time: 2024-10-08 14:06UTC to 2024-10-08 14:12UTC

Event contains 922 original clicks, 461 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 247 clicks) .

Median statistics for 247 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.94
Median 10dB Center Frequency [kHz] 5.92
Median 3dB Bandwidth [kHz] (lower-upper) 0.938 (5.44 - 6.45)
Median 10dB Bandwidth [kHz] (lower-upper) 2.22 (4.76 - 7.02)
Median duration [μs] (25-75 percentile) 1097 (1000 - 1672)

Event ID: 7518.241008143000.wav

Time: 2024-10-08 14:30UTC to 2024-10-08 14:36UTC

Event contains 1932 original clicks, 966 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 617 clicks) .

Median statistics for 617 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.08
Median 10dB Center Frequency [kHz] 6.09
Median 3dB Bandwidth [kHz] (lower-upper) 1.08 (5.45 - 6.76)
Median 10dB Bandwidth [kHz] (lower-upper) 2.63 (4.64 - 7.48)
Median duration [μs] (25-75 percentile) 855 (318 - 1322)

Event ID: 7518.241008143600.wav

Time: 2024-10-08 14:36UTC to 2024-10-08 14:42UTC

Event contains 900 original clicks, 450 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 400 clicks) .

Median statistics for 400 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6.4
Median 3dB Center Frequency [kHz] 6.39
Median 10dB Center Frequency [kHz] 6.22
Median 3dB Bandwidth [kHz] (lower-upper) 1.25 (5.74 - 7.2)
Median 10dB Bandwidth [kHz] (lower-upper) 3.44 (4.33 - 8.03)
Median duration [μs] (25-75 percentile) 296 (107 - 1000)

Event ID: 7518.241009060600.wav

Time: 2024-10-09 06:06UTC to 2024-10-09 06:12UTC

Event contains 922 original clicks, 461 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 274 clicks) .

Median statistics for 274 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.13
Median 10dB Center Frequency [kHz] 6.07
Median 3dB Bandwidth [kHz] (lower-upper) 1.04 (5.58 - 6.67)
Median 10dB Bandwidth [kHz] (lower-upper) 2.51 (4.77 - 7.26)
Median duration [μs] (25-75 percentile) 486 (139 - 1032)

Event ID: 7518.241009063000.wav

Time: 2024-10-09 06:30UTC to 2024-10-09 06:36UTC

Event contains 1050 original clicks, 525 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 402 clicks) .

Median statistics for 402 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.89
Median 10dB Center Frequency [kHz] 5.85
Median 3dB Bandwidth [kHz] (lower-upper) 1.05 (5.32 - 6.44)
Median 10dB Bandwidth [kHz] (lower-upper) 2.36 (4.62 - 7.02)
Median duration [μs] (25-75 percentile) 791 (315 - 1369)

Event ID: 7518.241009095400.wav

Time: 2024-10-09 09:54UTC to 2024-10-09 10:00UTC

Event contains 402 original clicks, 201 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 143 clicks) .

Median statistics for 143 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 10.8
Median 3dB Center Frequency [kHz] 9.1
Median 10dB Center Frequency [kHz] 9.76
Median 3dB Bandwidth [kHz] (lower-upper) 1.4 (8.59 - 9.66)
Median 10dB Bandwidth [kHz] (lower-upper) 4.05 (6.73 - 12.5)
Median duration [μs] (25-75 percentile) 96 (13 - 308)

Event ID: 7518.241009100000.wav

Time: 2024-10-09 10:00UTC to 2024-10-09 10:06UTC

Event contains 514 original clicks, 257 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 176 clicks) .

Median statistics for 176 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 12.8
Median 3dB Center Frequency [kHz] 11.7
Median 10dB Center Frequency [kHz] 11.8
Median 3dB Bandwidth [kHz] (lower-upper) 1.34 ( 11 - 12.6)
Median 10dB Bandwidth [kHz] (lower-upper) 3.86 (7.88 - 14.1)
Median duration [μs] (25-75 percentile) 120 (7 - 283)

Event ID: 7518.241009100600.wav

Time: 2024-10-09 10:06UTC to 2024-10-09 10:12UTC

Event contains 454 original clicks, 227 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 150 clicks) .

Median statistics for 150 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 8.4
Median 3dB Center Frequency [kHz] 8.16
Median 10dB Center Frequency [kHz] 8.17
Median 3dB Bandwidth [kHz] (lower-upper) 1.33 (7.33 - 9.17)
Median 10dB Bandwidth [kHz] (lower-upper) 3.38 (6.27 - 10.2)
Median duration [μs] (25-75 percentile) 138 (11 - 325)

Event ID: 7518.241010012401.wav

Time: 2024-10-10 01:24UTC to 2024-10-10 01:30UTC

Event contains 488 original clicks, 244 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 44 clicks) .

Median statistics for 44 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 12.8
Median 3dB Center Frequency [kHz] 10.9
Median 10dB Center Frequency [kHz] 10.8
Median 3dB Bandwidth [kHz] (lower-upper) 0.595 (10.5 - 11.2)
Median 10dB Bandwidth [kHz] (lower-upper) 1.38 (9.82 - 11.6)
Median duration [μs] (25-75 percentile) 233 (100 - 1000)

Event ID: 7518.241010105401.wav

Time: 2024-10-10 10:54UTC to 2024-10-10 11:00UTC

Event contains 400 original clicks, 200 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 101 clicks) .

Median statistics for 101 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.04
Median 10dB Center Frequency [kHz] 6.05
Median 3dB Bandwidth [kHz] (lower-upper) 1.1 ( 5.5 - 6.69)
Median 10dB Bandwidth [kHz] (lower-upper) 2.53 (4.73 - 7.37)
Median duration [μs] (25-75 percentile) 214 (100 - 1000)

Event ID: 7518.241011005401.wav

Time: 2024-10-11 00:54UTC to 2024-10-11 01:00UTC

Event contains 786 original clicks, 393 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 176 clicks) .

Median statistics for 176 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 8.2
Median 3dB Center Frequency [kHz] 7.91
Median 10dB Center Frequency [kHz] 7.91
Median 3dB Bandwidth [kHz] (lower-upper) 0.713 (7.51 - 8.39)
Median 10dB Bandwidth [kHz] (lower-upper) 2.38 (6.26 - 9.56)
Median duration [μs] (25-75 percentile) 1309 (159 - 1988)

Event ID: 7518.241011010001.wav

Time: 2024-10-11 01:00UTC to 2024-10-11 01:06UTC

Event contains 564 original clicks, 282 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 155 clicks) .

Median statistics for 155 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 8.8
Median 3dB Center Frequency [kHz] 8.44
Median 10dB Center Frequency [kHz] 8.54
Median 3dB Bandwidth [kHz] (lower-upper) 0.729 (7.95 - 8.78)
Median 10dB Bandwidth [kHz] (lower-upper) 2.27 (7.21 - 10.1)
Median duration [μs] (25-75 percentile) 1374 (1000 - 1890)

Event ID: 7518.241011183601.wav

Time: 2024-10-11 18:36UTC to 2024-10-11 18:42UTC

Event contains 456 original clicks, 228 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 43 clicks) .

Median statistics for 43 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 9.2
Median 3dB Center Frequency [kHz] 8.07
Median 10dB Center Frequency [kHz] 8.23
Median 3dB Bandwidth [kHz] (lower-upper) 0.605 (7.74 - 8.41)
Median 10dB Bandwidth [kHz] (lower-upper) 1.65 (7.41 - 9.73)
Median duration [μs] (25-75 percentile) 63 (33 - 100)

Event ID: 7518.241012081801.wav

Time: 2024-10-12 08:18UTC to 2024-10-12 08:24UTC

Event contains 1076 original clicks, 538 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 325 clicks) .

Median statistics for 325 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.89
Median 10dB Center Frequency [kHz] 5.86
Median 3dB Bandwidth [kHz] (lower-upper) 1.06 (5.33 - 6.52)
Median 10dB Bandwidth [kHz] (lower-upper) 2.56 (4.54 - 7.2)
Median duration [μs] (25-75 percentile) 115 (5 - 274)

Event ID: 7518.241012082401.wav

Time: 2024-10-12 08:24UTC to 2024-10-12 08:30UTC

Event contains 628 original clicks, 314 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 181 clicks) .

Median statistics for 181 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 6.02
Median 10dB Center Frequency [kHz] 6.01
Median 3dB Bandwidth [kHz] (lower-upper) 1.08 (5.41 - 6.58)
Median 10dB Bandwidth [kHz] (lower-upper) 2.56 (4.67 - 7.25)
Median duration [μs] (25-75 percentile) 0 (0 - 26)

Event ID: 7518.241012134801.wav

Time: 2024-10-12 13:48UTC to 2024-10-12 13:54UTC

Event contains 3682 original clicks, 1841 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 953 clicks) .

Median statistics for 953 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6.4
Median 3dB Center Frequency [kHz] 6.37
Median 10dB Center Frequency [kHz] 6.7
Median 3dB Bandwidth [kHz] (lower-upper) 1.34 (5.54 - 7.24)
Median 10dB Bandwidth [kHz] (lower-upper) 4.2 (4.26 - 8.96)
Median duration [μs] (25-75 percentile) 125 (16 - 328)

Event ID: 7518.241012135401.wav

Time: 2024-10-12 13:54UTC to 2024-10-12 14:00UTC

Event contains 4622 original clicks, 2311 valid clicks after filtering.

Click plots and table

SNR histogram includes all filtered clicks. Other plots contain only clicks with SNR >= 15 dB (n = 1201 clicks) .

Median statistics for 1201 high SNR clicks with SNR >= 15 dB.
parameter value
Median Peak Frequency [kHz] 6
Median 3dB Center Frequency [kHz] 5.4
Median 10dB Center Frequency [kHz] 5.98
Median 3dB Bandwidth [kHz] (lower-upper) 1.16 (4.77 - 6.11)
Median 10dB Bandwidth [kHz] (lower-upper) 4.03 (3.51 - 8.27)
Median duration [μs] (25-75 percentile) 276 (44 - 1000)

Clean up Event Table

# clean up the event table
evTable <- evTable[evTable$keep == TRUE,]
evTable <- subset(evTable, select = -keep)
# save event table as CSV
write.csv(evTable, file = file.path(params$path_dets, 
                                    paste0('eventTable_', params$mission, '_', 
                                           params$drift, '_', Sys.Date(),'.csv')))

#dbDisconnect(dbFile)

After additional filtering based on median peak frequency, 41 events events of 1406 original events remain.